﻿using RuTracker.Interface;

namespace RuTrackerLib.Editors.Links.Editors
{
    static class LinkEditorFactory
    {
        public static ILinkEditor GetLinkEditor(Link link, ISessionStorage sessionStorage, string directory)
        {
            if (link.HRef.StartsWith("http"))
                return new HttpLinkEditor();

            if (link.HRef.StartsWith("./"))
                return new CurrentDirectoryEditor(directory);

            if (link.HRef.StartsWith("../"))
                return new ParentLinkEditor(directory);

            if (link.HRef.Contains("search_id"))
                return new SearchLinkEditor(sessionStorage, directory);

            return new GenericLinkEditor(directory);
        }
    }
}
